home *** CD-ROM | disk | FTP | other *** search
/ STraTOS 1997 April & May / STraTOS 1 - 1997 April & May.iso / CD01 / INTERNET / SITES / GRAHAM / XA_6S.ZIP / SOURCE / DRAG_BOX.C < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-27  |  4.0 KB  |  171 lines

  1. /*
  2.  * XaAES - XaAES Ain't the AES
  3.  *
  4.  * A multitasking AES replacement for MiNT
  5.  *
  6.  */
  7.  
  8. #include <VDI.H>
  9. #include "XA_DEFS.H"
  10. #include "XA_TYPES.H"
  11. #include "K_DEFS.H"
  12. #include "XA_GLOBL.H"
  13.  
  14. /*
  15.     Ghost outline dragging routines - all coded to work with full rectangles instead of outlines
  16. */
  17. void drag_box(short w, short h, short xs, short ys, short bx, short by, short bw, short bh, short *xe, short *ye)
  18. {
  19.     short x,y,mb, idx, idy, dx,dy, odx=-1, ody=-1;
  20.     short pnt[4];
  21.     
  22.     vq_mouse(V_handle, &mb, &x, &y);
  23.     vswr_mode(V_handle, MD_XOR);
  24.  
  25.     vsf_color(V_handle,BLACK);
  26.     vsf_perimeter(V_handle,0);
  27.     
  28.     idx=x-xs; idy=y-ys;
  29.     
  30.     while(mb)
  31.     {
  32.         vq_mouse(V_handle, &mb, &x, &y);
  33.         dx=x-idx; dy=y-idy;
  34.         
  35.         if (dx<bx)        /* Ensure we are inside the bounding rectangle */
  36.         {
  37.             dx=bx;
  38.         }else{
  39.             if (dx+w>bx+bw) dx=bx+bw-w-1;
  40.         }
  41.         if (dy<by)
  42.         {
  43.             dy=by;
  44.         }else{
  45.             if (dy+h>by+bh) dy=by+bh-h-1;
  46.         }
  47.         
  48.         if ((dx!=odx)||(dy!=ody))
  49.         {
  50.             v_hide_c(V_handle);
  51.             if (odx!=-1)
  52. #if SOLID_BOXES
  53.                 v_bar(V_handle,pnt);        /* This is a real man's GUI - dragged boxs can be done as solid */
  54.  
  55.             pnt[0]=dx; pnt[1]=dy; pnt[2]=dx+w; pnt[3]=dy+h;
  56.             v_bar(V_handle,pnt);
  57. #else
  58.             {
  59.                 pnt[0]=odx; pnt[1]=ody; pnt[2]=odx+w-1; pnt[3]=ody+1;
  60.                 v_bar(V_handle,pnt);
  61.                 pnt[0]=odx+w; pnt[1]=ody; pnt[2]=odx+w+1; pnt[3]=ody+h-1;
  62.                 v_bar(V_handle,pnt);
  63.                 pnt[0]=odx+w; pnt[1]=ody+h; pnt[2]=odx+1; pnt[3]=ody+h+1;
  64.                 v_bar(V_handle,pnt);
  65.                 pnt[0]=odx; pnt[1]=ody+1; pnt[2]=odx+1; pnt[3]=ody+h;
  66.                 v_bar(V_handle,pnt);
  67.             }
  68.                 
  69.             pnt[0]=dx; pnt[1]=dy; pnt[2]=dx+w-1; pnt[3]=dy+1;
  70.             v_bar(V_handle,pnt);
  71.             pnt[0]=dx+w; pnt[1]=dy; pnt[2]=dx+w+1; pnt[3]=dy+h-1;
  72.             v_bar(V_handle,pnt);
  73.             pnt[0]=dx+w; pnt[1]=dy+h; pnt[2]=dx+1; pnt[3]=dy+h+1;
  74.             v_bar(V_handle,pnt);
  75.             pnt[0]=dx; pnt[1]=dy+1; pnt[2]=dx+1; pnt[3]=dy+h;
  76.             v_bar(V_handle,pnt);
  77. #endif
  78.             v_show_c(V_handle, 1);
  79.             odx=dx; ody=dy;
  80.         }
  81.     }
  82.     
  83.     if (odx!=-1)
  84.     {
  85.         v_hide_c(V_handle);
  86.         pnt[0]=dx; pnt[1]=dy; pnt[2]=dx+w-1; pnt[3]=dy+1;
  87.         v_bar(V_handle,pnt);
  88.         pnt[0]=dx+w; pnt[1]=dy; pnt[2]=dx+w+1; pnt[3]=dy+h-1;
  89.         v_bar(V_handle,pnt);
  90.         pnt[0]=dx+w; pnt[1]=dy+h; pnt[2]=dx+1; pnt[3]=dy+h+1;
  91.         v_bar(V_handle,pnt);
  92.         pnt[0]=dx; pnt[1]=dy+h; pnt[2]=dx+1; pnt[3]=dy+1;
  93.         v_bar(V_handle,pnt);
  94.         v_show_c(V_handle, 1);
  95.     }
  96.  
  97.     vswr_mode(V_handle, MD_TRANS);
  98.     
  99.     *xe=dx; *ye=dy;
  100. }
  101.  
  102. void rubber_box(short sx, short sy, short minw, short minh, short *lastw, short *lasth)
  103. {
  104.     short x,y,mb,dw,dh, odw=-1, odh=-1;
  105.     short pnt[4];
  106.     
  107.     vswr_mode(V_handle, MD_XOR);
  108.     vq_mouse(V_handle, &mb, &x, &y);
  109.  
  110.     vsf_color(V_handle,BLACK);
  111.     vsf_perimeter(V_handle,0);
  112.  
  113.     while(mb)
  114.     {
  115.         vq_mouse(V_handle, &mb, &x, &y);
  116.         dw=x-sx; dh=y-sy;
  117.         
  118.         if (dw<minw)
  119.             dw=minw;
  120.  
  121.         if (dh<minh)
  122.             dh=minh;
  123.         
  124.         if ((dw!=odw)||(dh!=odh))
  125.         {
  126.             v_hide_c(V_handle);
  127.             if (odw!=-1)
  128.             {
  129.                 pnt[0]=sx; pnt[1]=sy; pnt[2]=sx+odw-1; pnt[3]=sy+1;
  130.                 v_bar(V_handle,pnt);
  131.                 pnt[0]=sx+odw; pnt[1]=sy; pnt[2]=sx+odw+1; pnt[3]=sy+odh-1;
  132.                 v_bar(V_handle,pnt);
  133.                 pnt[0]=sx+odw; pnt[1]=sy+odh; pnt[2]=sx+1; pnt[3]=sy+odh+1;
  134.                 v_bar(V_handle,pnt);
  135.                 pnt[0]=sx; pnt[1]=sy+odh; pnt[2]=sx+1; pnt[3]=sy+1;
  136.                 v_bar(V_handle,pnt);
  137.             }
  138.             pnt[0]=sx; pnt[1]=sy; pnt[2]=sx+dw-1; pnt[3]=sy+1;
  139.             v_bar(V_handle,pnt);
  140.             pnt[0]=sx+dw; pnt[1]=sy; pnt[2]=sx+dw+1; pnt[3]=sy+dh-1;
  141.             v_bar(V_handle,pnt);
  142.             pnt[0]=sx+dw; pnt[1]=sy+dh; pnt[2]=sx+1; pnt[3]=sy+dh+1;
  143.             v_bar(V_handle,pnt);
  144.             pnt[0]=sx; pnt[1]=sy+dh; pnt[2]=sx+1; pnt[3]=sy+1;
  145.             v_bar(V_handle,pnt);
  146.  
  147.             v_show_c(V_handle, 1);
  148.             odw=dw; odh=dh;
  149.         }
  150.     }
  151.     
  152.     if (odw!=-1)
  153.     {
  154.         v_hide_c(V_handle);
  155.         pnt[0]=sx; pnt[1]=sy; pnt[2]=sx+dw-1; pnt[3]=sy+1;
  156.         v_bar(V_handle,pnt);
  157.         pnt[0]=sx+dw; pnt[1]=sy; pnt[2]=sx+dw+1; pnt[3]=sy+dh-1;
  158.         v_bar(V_handle,pnt);
  159.         pnt[0]=sx+dw; pnt[1]=sy+dh; pnt[2]=sx+1; pnt[3]=sy+dh+1;
  160.         v_bar(V_handle,pnt);
  161.         pnt[0]=sx; pnt[1]=sy+dh; pnt[2]=sx+1; pnt[3]=sy+1;
  162.         v_bar(V_handle,pnt);
  163.         v_show_c(V_handle, 1);
  164.     }
  165.  
  166.     vswr_mode(V_handle, MD_TRANS);
  167.     
  168.     *lastw=dw; *lasth=dh;
  169. }
  170.  
  171.